<template>
  <div class="data_fans">
    <el-row :gutter="16" v-loading="loading">
      <el-col :xs="24" :sm="24" :md="12">
        <el-card class="mb-4" header="性别分布">
          <pie-chart class="h-[30vh]" :data="data.fansGender" v-if="!loading" />
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12">
        <el-card class="mb-4" header="年龄分布">
          <bar-chart class="h-[30vh]" :data="data.fansAge" v-if="!loading" />
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12">
        <el-card class="mb-4" header="地域分布">
          <map-chart class="h-[30vh]" :data="data.fansArea" v-if="!loading" />
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12">
        <el-card class="mb-4" header="设备分布">
          <pie-chart class="h-[30vh]" :data="data.fansClient" v-if="!loading" />
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref, reactive, computed } from "vue"
import { getFansDataApi } from "@/api/data"
// import PieChart from "@/views/DataCenter/components/pieChart.vue";
// import pieChart from './components/pie.vue'
// import barChart from './components/bar.vue'
// import mapChart from './components/map.vue'

defineOptions({
  name: "data_fans",
})

const loading = ref(true)
const data = reactive({
  fansArea: [], // 粉丝地域分布数据
  fansGender: [], // 粉丝性别分布数据
  fansAge: [], // 粉丝年龄分布数据
  fansClient: [], // 粉丝客户端分布数据
})
const getFansData = async () => {
  const res = await getFansDataApi()
  if (res.success) {
    Object.assign(data, res.data)
  }
  loading.value = false
}

getFansData()
// const props = defineProps({
//   modelValue: {
//     type: String,
//   },
//   content: {
//     type: String,
//     default: '',
//   },
// });
</script>

<style lang="scss" scoped></style>
